<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<div class="row border-bottom">
	<nav class="navbar navbar-static-top" role="navigation"
		style="margin-bottom: 0">
		<div class="navbar-header">
			<a class="navbar-minimalize minimalize-styl-2 btn btn-primary "
				href="#"><i class="fa fa-bars"></i> </a>
		</div>
		<ul class="nav navbar-top-links navbar-right">
			<li><span class="m-r-sm text-muted welcome-message"><a
					href="${ctx}/login/main" title="返回首页"><i class="fa fa-home"></i></a>停简单开放平台管理系统</span>
			</li>
			<li><a href="${ctx}/login/logout"> <i class="fa fa-sign-out"></i> 退出
			</a></li>
		</ul>

	</nav>
</div>

<script type="text/javascript">
$(function() {
	$("#passwordForm").validate({
		focusCleanup:true,
		focusInvalid:false,
		onkeyup:true,
		ignore:"input:radio[name=parentCode]",
		rules : {
			oldPassword : {
				required : true,
				minlength : 1,
				maxlength:25,
				remote:{
					url :ctx+'/gmUser/checkOldPassword',
					type:'post',
					data:{
						oldPassword:function(){
							return $("#oldPassword").val();
						}
					}
				}
			},
			
			password : {
				required : true,
				minlength : 1,
				maxlength:25
			},
			passwordConfirm : {
				equalTo:"#password",
				required : true,
				minlength : 1,
				maxlength:25
			}
			
		},
		messages : {
			oldPassword:{
				required : "请输入旧密码",
				minlength : "密码不能小于1",
				maxlength:"密码不能大于25",
				remote :"旧密码不正确,请修改正确！"
			},
			password:{
				required : "请输入新密码",
				minlength : "新密码不能小于1",
				maxlength:"新密码不能大于25",
			},
			passwordConfirm : {
				equalTo : "两次输入的密码不同,请重新输入",
				required : "请输入确认新密码",
				minlength : "新密码不能小于1",
				maxlength:"新密码不能大于25",
			}
		},
		submitHandler:submit
	});
});


/**
 * 表单提交
 */
function submit(){
	$.ajax({
		url : ctx + '/gmUser/updatePassword',
		type : 'post',
		dataType : 'json',
		timeout : ajaxTimeout,
		data : $('#passwordForm').serialize(),
		error : function(json) {
			//showMsgDiv(false,"添加失败",$("#msgSpan"),$("#msgDiv"),3000);
			toastr.error("修改失败");
			
		},
		success : function(json) {
			//showMsgDiv(json.isSuccess,json.msg,$("#msgSpan"),$("#msgDiv"),3000);
			if(json.isSuccess){
				toastr.success(json.msg);
			}else{
				toastr.error(json.msg);
			}
		}
	});
}


</script>

 <div class="modal inmodal" id="passwordModel" tabindex="-1" role="dialog"  aria-hidden="true">
                                <div class="modal-dialog">
                                 <form class="form-horizontal m-t" id="passwordForm" method="post" action="#">
                                    <div class="modal-content animated fadeIn">
                                        <div class="modal-header">
                                            <i class="fa fa-lock modal-icon"></i>
                                        </div>
                                        <div class="modal-body">
                                          
                                           		  <div class="form-group">
			                                        <label class="col-sm-3 control-label">旧密码：</label>
			                                        <div class="col-sm-7">
			                                            <input id="oldPassword" name="oldPassword"  class="form-control" placeholder="请输入旧密码" type="password">
			                                        </div>
			                                   	  </div>
			                                   	   <div class="form-group">
				                                        <label class="col-sm-3 control-label">新密码：</label>
				                                        <div class="col-sm-7">
				                                            <input id="password" name="password"  class="form-control" placeholder="请输入新密码" type="password">
				                                        </div>
				                                    </div>
			                                     <div class="form-group">
			                                        <label class="col-sm-3 control-label">确认新密码：</label>
			                                        <div class="col-sm-7">
			                                            <input id="passwordConfirm" name="passwordConfirm" class="form-control"  placeholder="请确认新密码" type="password">
			                                        </div>
			                                    </div>
                                          
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit" class="btn btn-primary">保存</button>
                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                        </div>
                                    </div>
                                     </form>
                                </div>
                            </div>